package br.ufal.ic.fracao.especialist;

import java.io.IOException;

import org.jdom.JDOMException;

import br.ufal.ic.fracao.especialist.domain.Item;
import br.ufal.ic.fracao.especialist.inference.InferenceAlgorithm;

public class Test {

	public String getAcao(){
        InferenceAlgorithm algorithm = new InferenceAlgorithm();

        Item fato1 = new Item();
        fato1.setDescription("M");
        fato1.setValue(String.valueOf(false));
        fato1.setCertaintyFactor(0.3);
        algorithm.addToMemoryWorking(fato1);
        
        Item fato2 = new Item();
        fato2.setDescription("SM-SB");
        fato2.setValue(String.valueOf(true));
        fato2.setCertaintyFactor(0.5);
        algorithm.addToMemoryWorking(fato2);
        
        Item fato3 = new Item();
        fato3.setDescription("SI");
        fato3.setValue(String.valueOf(false));
        fato3.setCertaintyFactor(0.2);
        algorithm.addToMemoryWorking(fato3);
        
        Item conclusion1 = new Item("Multiplicar", "true");
        Item conclusion2 = new Item("Somar-Subtrair", "true");
        Item conclusion3 = new Item("Simplificar", "true");
        try {
            if (algorithm.doForwardChaining(conclusion1, false).equalsIgnoreCase("Multiplicar")) {
                return "Multiplicar";
            } else if (algorithm.doForwardChaining(conclusion2, false).equalsIgnoreCase("Somar-Subtrair")) {
                return "Somar-Subtrair";
            } else if (algorithm.doForwardChaining(conclusion3, false).equalsIgnoreCase("Simplificar")) {
                return "Simplificar";
            }
        } catch (JDOMException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return null;
    }
    	
	public static void main(String[] args) {
		Test t = new Test();
		System.out.println(t.getAcao());
	}
	
}
